import 'dart:io';

class Tally {
  int id;
  String status;
  String containerNo;
  String inboundNo;
  int type;

  Tally(this.id, this.status, this.containerNo, this.inboundNo, this.type);

  Tally.fromJson(Map<dynamic, dynamic> json)
      : id = json['id'] as int,
        status = json['status'] as String,
        containerNo = json['containerNo'] as String,
        inboundNo = json['inboundNo'] as String,
        type = json['type'] as int;
}

class TallyDetail {
  int id;
  String sku;
  int skuQty;
  int tallyQty;
  int lpnQty;
  int damageQty;
  bool isEquals;
  List<Lpns> list;

  TallyDetail(this.id, this.sku, this.skuQty, this.tallyQty, this.lpnQty, this.damageQty, this.isEquals, this.list);

  bool click = false;

  TallyDetail.fromJson(Map<dynamic, dynamic> json)
      : id = json['id'] as int,
        sku = json['sku'] as String,
        skuQty = json['skuQty'] as int,
        tallyQty = json['tallyQty'] as int,
        lpnQty = json['lpnQty'] as int,
        damageQty = json['damageQty'] as int,
        isEquals = json['isEquals'] as bool,
        list = json['list'] == null ? null : (new List<dynamic>.from(json['list']).map((userJson) => Lpns.fromJson(userJson)).toList());
}

class Lpns {
  int inventory;
  String lpn;
  String type = "good";

  Lpns(this.inventory, this.lpn, this.type);

  Lpns.fromJson(Map<dynamic, dynamic> json)
      : inventory = json['inventory'] as int,
        lpn = json['lpn'] as String,
        type = json['type'] as String;
}

class TallyQr {
  int notifyId = -1; //柜号Id
  int warehousingNotifyId = -1; //柜号Id
  String lpn; //lpn

  String ibLpn; //lpn
  String location;
  String container_no; //集装箱

  String inboundNo; //入库编号
  String sku_barcode; //barcod数量
  String sku; //sku

  int quantity; //数量
  int ctnQty; //ctn数量
  int pcsQty; //pcs数量

  String upType; //上架方式CTN/QPS
  int warehousingDetailId; //详情id
  double weight; //货运毛重(KG)

  double length;
  double width;
  double height;

  String lengthPhoto;
  String widthPhoto;
  String heightPhoto;

  String weightPhoto;
  List<String> damagePhotos = new List(); //破损图片

  String type = "good"; //类型 good/damage
  int isFinish; //
  String status;

  TallyQr.name(this.notifyId, this.container_no, this.inboundNo, this.warehousingDetailId, this.isFinish, this.status);

  TallyQr(this.notifyId, this.warehousingNotifyId, this.lpn, this.ibLpn, this.location, this.container_no, this.inboundNo, this.sku_barcode, this.sku, this.quantity, this.ctnQty, this.pcsQty, this.upType, this.warehousingDetailId, this.weight, this.length, this.width,
      this.height, this.lengthPhoto, this.widthPhoto, this.heightPhoto, this.weightPhoto, this.damagePhotos, this.type, this.isFinish, this.status); //


  Map<String, dynamic> toJson() => {
    'notifyId': notifyId,
    'warehousingNotifyId': warehousingNotifyId,
    'lpn': lpn,
    'ibLpn': ibLpn,
    'location': location,

    'container_no': container_no,
    'inboundNo': inboundNo,
    'sku_barcode': sku_barcode,
    'sku': sku,
    'quantity': quantity,

    'ctnQty': ctnQty,
    'pcsQty': pcsQty,
    'upType': upType,
    'warehousingDetailId': warehousingDetailId,
    'weight': weight,

    'length': length,
    'width': width,
    'height': height,
    'lengthPhoto': lengthPhoto,
    'widthPhoto': widthPhoto,

    'heightPhoto': heightPhoto,
    'weightPhoto': weightPhoto,
    'damagePhotos': damagePhotos,
    'type': type,
    'isFinish': isFinish,
    'status': status,
  };

  TallyQr.fromJson(Map<dynamic, dynamic> json)
      : notifyId = json['notifyId'] as int,
        warehousingNotifyId = json['warehousingNotifyId'] as int,
        lpn = json['lpn'] as String,
        ibLpn = json['ibLpn'] as String,
        location = json['location'] as String,

        container_no = json['container_no'] as String,
        inboundNo = json['inboundNo'] as String,
        sku_barcode = json['sku_barcode'] as String,
        sku = json['sku'] as String,
        quantity = json['quantity'] as int,

        ctnQty = json['ctnQty'] as int,
        pcsQty = json['pcsQty'] as int,
        upType = json['upType'] as String,
        warehousingDetailId = json['warehousingDetailId'] as int,
        weight = json['weight'] as double,

        length = json['length'] as double,
        width = json['width'] as double,
        height = json['height'] as double,
        lengthPhoto = json['lengthPhoto'] as String,
        widthPhoto = json['widthPhoto'] as String,

        heightPhoto = json['heightPhoto'] as String,
        weightPhoto = json['weightPhoto'] as String,
        damagePhotos = json['damagePhotos'] == null ? null : new List<String>.from(json['damagePhotos']) as List<String>,
        type = json['type'] as String,
        isFinish = json['isFinish'] as int,
        status = json['status'] as String;
}

class TallyFinishQr {
  int id;

  // int tallyPalletQty;

  TallyFinishQr(this.id);

  Map<String, dynamic> toJson() => {
        'id': id,
      };
}

class TallySkuBase {
  int warehousingDetailId; //预报详情id
  String sku; //sku
  String upType; //上架方式
  SkuBaseRespVoDTO skuBaseRespVo;
  bool isShowSkuBase; //是否回显sku尺寸
  List<String> barcodes; //barcode列表

  TallySkuBase(
    this.warehousingDetailId,
    this.sku,
    this.upType,
    this.skuBaseRespVo,
    this.isShowSkuBase,
    this.barcodes,
  );

  TallySkuBase.fromJson(Map<dynamic, dynamic> json)
      : warehousingDetailId = json['warehousingDetailId'] as int,
        sku = json['sku'] as String,
        upType = json['upType'] as String,
        skuBaseRespVo = SkuBaseRespVoDTO.fromJson(json['skuBaseRespVo']),
        isShowSkuBase = json['isShowSkuBase'] as bool,
        barcodes = json['barcodes'] == null ? null : new List<String>.from(json['barcodes']) as List<String>;
}

class SkuBaseRespVoDTO {
  String sku; //sku
  double length;
  double width;
  double height;
  double weight;
  String lengthPhoto;
  String widthPhoto;
  String heightPhoto;
  String weightPhoto;
  List<String> damagePhotos;
  bool smallItem;

  SkuBaseRespVoDTO(this.sku, this.length, this.width, this.height, this.weight, this.lengthPhoto, this.widthPhoto, this.heightPhoto, this.weightPhoto, this.damagePhotos, this.smallItem);

  SkuBaseRespVoDTO.fromJson(Map<dynamic, dynamic> json)
      : sku = json['sku'] as String,
        length = json['length'] as double,
        width = json['width'] as double,
        height = json['height'] as double,
        weight = json['weight'] as double,
        lengthPhoto = json['lengthPhoto'] as String,
        widthPhoto = json['widthPhoto'] as String,
        heightPhoto = json['heightPhoto'] as String,
        weightPhoto = json['weightPhoto'] as String,
        damagePhotos = json['damagePhotos'] == null ? null : new List<String>.from(json['damagePhotos']) as List<String>,
        smallItem = json['smallItem'] as bool;
}

class CheckSkuParam {
  int warehousingNotifyId;
  String sku;
  List<double> sizes = new List();
  double weight;
  bool smallItem;


  Map<String, dynamic> toJson() => {
        'warehousingNotifyId': warehousingNotifyId,
        'sku': sku,
        'sizes': sizes,
        'weight': weight,
        'smallItem': smallItem,
      };

  CheckSkuParam.fromJson(Map<dynamic, dynamic> json)
      : warehousingNotifyId = json['warehousingNotifyId'] as int,
        sku = json['sku'] as String,
        sizes = json['sizes'] == null ? null : new List<double>.from(json['sizes']) as List<double>,
        weight = json['weight'] as double,
        smallItem = json['smallItem'] as bool;

  CheckSkuParam({
    this.warehousingNotifyId,
    this.sku,
    this.sizes,
    this.weight,
    this.smallItem,
  });
}

class SkuExceed {
  bool isLength;
  bool isWidth;
  bool isHeight;
  bool isWeight;
  bool smallItem;
}

class TallyLPN {
  String sku;
  int quantity;
  int qty;
  String wholeCode;

  TallyLPN(this.sku, this.quantity, this.qty, this.wholeCode);

  TallyLPN.fromJson(Map<dynamic, dynamic> json)
      : sku = json['sku'] as String,
        quantity = json['quantity'] as int,
        qty = json['qty'] as int,
        wholeCode = json['qty'] as String;
}
